db = require '../base/db'

Schema = db.Schema
mongoose = db.mongoose
updated_at = db.mongoose_plugins.updated_at

# 模型
DepartmentSchema = new Schema
  # ID
  department_id: String
  # 名称
  department_name: String
  # 时间
  curr_date: Date
  #  检查事项
  examine_thing:String
  # 附件 
  file_url:String
  #
  # 备注
  remark:String
  # 扩展字段
  extra: Schema.Types.Mixed

# 是否自动索引
DepartmentSchema.set('autoIndex', false)
# 设置ID为索引
DepartmentSchema.index {department_id: 1}, {unique: false}
# 设置更新时间
DepartmentSchema.plugin updated_at, {index: true}

# 向外导出模型
module.exports = mongoose.model 'otc_departments', DepartmentSchema